import 'package:flutter/material.dart';
import './call_screen.dart';
import './camera_screen.dart';
import './chat_screen.dart';
import './status_screen.dart';

class TabsPage extends StatefulWidget {
  const TabsPage({Key? key}) : super(key: key);
  // final dynamic camera;

  @override
  _TabsPageState createState() => _TabsPageState();
}

class _TabsPageState extends State<TabsPage> with SingleTickerProviderStateMixin {
  late TabController _tabController;
  bool showFab = true;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(vsync: this, initialIndex: 0, length: 4);
    _tabController.addListener(() {
      if (_tabController.index == 1) {
        showFab = true;
      } else {
        showFab = false;
      }
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
            title: Text('whatsApp1'),
            elevation: 0.7,
            bottom: TabBar(
                controller: _tabController,
                indicatorColor: Colors.white,
                tabs: [
                  Tab(icon: Icon(Icons.camera_alt)),
                  Tab(text: 'CHATS'),
                  Tab(text: 'STATUS'),
                  Tab(text: 'CALLS')
                ]),
            actions: [
              Icon(Icons.search),
              Padding(padding: const EdgeInsets.symmetric(horizontal: 5.0))
            ]),
        body: TabBarView(
          controller: _tabController,
          children: [
            CameraScreen(),
            ChatScreen(),
            StatusScreen(),
            CallScreen()
          ],
        ),
        floatingActionButton: showFab
            ? FloatingActionButton(
                onPressed: () => {},
                backgroundColor: Theme.of(context).indicatorColor,
                child: Icon(Icons.message, color: Colors.white),
              )
            : null);
  }
}
